package com.zxy.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zxy.common.result.Result;
import com.zxy.pojo.dto.DeptQueryDTO;
import com.zxy.pojo.entity.SysDept;
import com.zxy.pojo.vo.SysDeptVO;
import com.zxy.service.SysDeptService;
import com.zxy.util.OperLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 部门Controller
 */
@RestController
@RequestMapping("/system/dept")
public class SysDeptController {

    @Autowired
    private SysDeptService sysDeptService;

    /**
     * 分页查询部门树形列表
     */
    @OperLog(title = "分页查询部门树形列表",businessType = 0,saveParams = true,saveResult = true)
    @GetMapping("/list")
    public Result<List<SysDeptVO>> getDeptList(DeptQueryDTO query) {
        // 关键：调用无分页的树形列表方法
        List<SysDeptVO> deptList = sysDeptService.getDeptTreeList(query);
        // 直接返回列表，Result会将其放在data字段中
        return Result.success(deptList);
    }
}

